# Maintainer: taozuhong <taozuhong@gmail.com>

_realname=xlsxio
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.2.29
pkgrel=2
pkgdesc="C library for reading and writing .xlsx files(mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://github.com/brechtsanders/xlsxio"
license=("MIT")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
            "${MINGW_PACKAGE_PREFIX}-pkgconf"
            "${MINGW_PACKAGE_PREFIX}-cmake"
            "${MINGW_PACKAGE_PREFIX}-expat"
            "${MINGW_PACKAGE_PREFIX}-libzip")
depends=("${MINGW_PACKAGE_PREFIX}-libzip"
         "${MINGW_PACKAGE_PREFIX}-expat")
source=("https://github.com/brechtsanders/xlsxio/archive/${pkgver}.tar.gz")
sha256sums=('0b6b4244420e8a2f492d09eae2abd6562c3113c22997673b0f2560bdb06d072f')

build() {
  mkdir -p "${srcdir}/build-${CARCH}"
  cd "${srcdir}/build-${CARCH}"

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  cmake -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DWITH_LIBZIP=ON \
    -DBUILD_TOOLS=OFF \
    -DBUILD_EXAMPLES=OFF \
    ../${_realname}-${pkgver}

  make
}

package() {
  cd "${srcdir}/build-${CARCH}"
  
  make DESTDIR="${pkgdir}" WITH_LIBZIP=1 install
}
